import time

from loguru import logger

# logger.debug('this is a debug message')
# logger.info('this is a info message')
# logger.warning('this is a  warning')
# logger.error('this is a error message')
#
# logger.success('this is a success message')
# logger.critical('this is a critical message')
#
# logger.add('my_log.log')
# logger.debug('this is  a debug message')
from ConfigFile.Varconfig import LogPath

class Log:

    # 单态、单例  --运行程序保证只有一个实例
    def __new__(cls, *args, **kwargs):
        if not hasattr(cls,'instance'):
            cls.instance = super(Log,cls).__new__(cls)
        return cls.instance

    def __init__(self):
        # tim = time.strftime("%Y-%m-%d_%H:%M:%S", time.localtime())
        logger.add(rotation='1 MB',sink=f'{LogPath}\\runtime_{time.time()}.log',)

    def debug(self,message):
        '''debug log'''
        logger.debug(message)

    def info(self,message):
        '''info log'''
        # tim = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
        # print(tim)
        logger.info(message)


    def error(self,message):
        '''error log'''
        logger.error(message)

    def warning(self,message):
        '''warning log'''
        logger.warning(message)


